// pages/cai/caicai.js
let numUser
let numComputer
let guessList
Page({
    data:{ 
      focus:true
    },
    onLoad: function (options) {
      console.log('onLoad...')
      guessList = []
      numComputer = parseInt(Math.random()*100+1)
      console.log('计算机想的数据=',numComputer)
    },
    input: function(e){
      numUser = parseInt(e.detail.value)
      console.log(numUser,typeof numUser)
    },
    caicai:function(e){
      guessList.push(numUser)
      console.log(guessList)
      let msg
      if (numUser == numComputer) {
        msg = "恭喜你猜对了"
      } else if (numUser < numComputer) {
        msg = "猜小了"
      } else if (numUser > numComputer) {
        msg = "猜大了"
      }
      setTimeout(() => {
        this.setData({msg : msg , inputValue : "" , focus : true , lastGuessData : numUser , guessList : guessList})
      },10);
    }
})